{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 12.2 案例实战 - 人脸识别模型"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 12.2.2 人脸数据读取、处理与变量提取"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1.读取人脸照片数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['10_0.jpg', '10_1.jpg', '10_2.jpg', '10_3.jpg', '10_4.jpg']"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import os\n",
    "names = os.listdir('olivettifaces')\n",
    "\n",
    "names[0:5]  # 查看前5项读取的文件名"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 获取到文件名称后，便可以通过如下代码在Python中查看这些图片\n",
    "from PIL import Image\n",
    "img0 = Image.open('olivettifaces\\\\' + names[0])\n",
    "img0.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAU60lEQVR4nF2ayW4kWRWGY7gxD5nhnOyschWu7lKDVBLdUrcEEhKieQCegVdiy44NEguExIYHYN2CRauhKFrqsrGdlXPMc7D4Mi+mvSiV05ER957z///5z7mhDsPwm9/85g9/+MN4PHZdN8syy7KeP39+e3ubZZnv+47j5Hle1/VoNLq8vHQcp67rzWbTtm0QBG3blmVpmmbf98fjMU1TXddt226aZrvd7vf7LMtM05zNZpqm6bre932apn3fW5YVRZFt26qqdl3Xti0XNE1TVZUQQlXVNE3fvHmTpul2u51Op2EYKorSdV3f94ZhKIpiGIZQFCVNU0VRrq6u/vGPf1iWNRqN7u7uxuPxdDptmiZNU276n//8Z71eB0Hgum4Yhtr5p6qqJEn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uMT7EXd3d23bLpfLL7/88v7+fr1e/+hHP/r444/TNH14eKBvwc8L/ExRFPv9nsbCNM2bm5v7+3vXdW9ubpiR+L5vWRav6wAhVi/nvnIDyvl9OCgrvbuEuBRl2i7+WpYl0z7exOY+P/vZzz7//PO//vWv6/X6o48+cl0XUTFNkxlUlmX/O3MezgeMwED2ytJpygukwkisy8+/9/P0Mvkj79+fjzp50Pe++71lfG+R8sP/ApOKLnaHoa3mAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=64x64 at 0x1C5B720B080>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "img0  # 在Jupyter Notebook中可以直接输入变量名查看图像"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2.人脸数据处理 - 特征变量提取"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[133, 100,  67, ...,  95, 106, 107],\n",
       "       [169,  78,  66, ...,  79, 106, 102],\n",
       "       [142,  73,  90, ...,  83,  97, 102],\n",
       "       ...,\n",
       "       [164, 105, 225, ...,  82,  73,  56],\n",
       "       [205, 220, 204, ..., 134, 142, 124],\n",
       "       [255, 254, 255, ..., 255, 252, 255]], dtype=uint8)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 图像灰度处理及数值化处理\n",
    "import numpy as np\n",
    "img0 = img0.convert('L')\n",
    "img0 = img0.resize((32, 32))\n",
    "arr = np.array(img0)\n",
    "\n",
    "arr  # 查看数值化后的结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>22</th>\n",
       "      <th>23</th>\n",
       "      <th>24</th>\n",
       "      <th>25</th>\n",
       "      <th>26</th>\n",
       "      <th>27</th>\n",
       "      <th>28</th>\n",
       "      <th>29</th>\n",
       "      <th>30</th>\n",
       "      <th>31</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>133</td>\n",
       "      <td>100</td>\n",
       "      <td>67</td>\n",
       "      <td>81</td>\n",
       "      <td>100</td>\n",
       "      <td>83</td>\n",
       "      <td>67</td>\n",
       "      <td>68</td>\n",
       "      <td>91</td>\n",
       "      <td>107</td>\n",
       "      <td>...</td>\n",
       "      <td>67</td>\n",
       "      <td>80</td>\n",
       "      <td>76</td>\n",
       "      <td>79</td>\n",
       "      <td>87</td>\n",
       "      <td>81</td>\n",
       "      <td>99</td>\n",
       "      <td>95</td>\n",
       "      <td>106</td>\n",
       "      <td>107</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>169</td>\n",
       "      <td>78</td>\n",
       "      <td>66</td>\n",
       "      <td>92</td>\n",
       "      <td>101</td>\n",
       "      <td>93</td>\n",
       "      <td>113</td>\n",
       "      <td>107</td>\n",
       "      <td>79</td>\n",
       "      <td>72</td>\n",
       "      <td>...</td>\n",
       "      <td>43</td>\n",
       "      <td>53</td>\n",
       "      <td>61</td>\n",
       "      <td>85</td>\n",
       "      <td>56</td>\n",
       "      <td>86</td>\n",
       "      <td>84</td>\n",
       "      <td>79</td>\n",
       "      <td>106</td>\n",
       "      <td>102</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>142</td>\n",
       "      <td>73</td>\n",
       "      <td>90</td>\n",
       "      <td>84</td>\n",
       "      <td>110</td>\n",
       "      <td>103</td>\n",
       "      <td>115</td>\n",
       "      <td>111</td>\n",
       "      <td>116</td>\n",
       "      <td>109</td>\n",
       "      <td>...</td>\n",
       "      <td>43</td>\n",
       "      <td>50</td>\n",
       "      <td>49</td>\n",
       "      <td>79</td>\n",
       "      <td>61</td>\n",
       "      <td>76</td>\n",
       "      <td>86</td>\n",
       "      <td>83</td>\n",
       "      <td>97</td>\n",
       "      <td>102</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>142</td>\n",
       "      <td>75</td>\n",
       "      <td>59</td>\n",
       "      <td>76</td>\n",
       "      <td>73</td>\n",
       "      <td>105</td>\n",
       "      <td>121</td>\n",
       "      <td>120</td>\n",
       "      <td>108</td>\n",
       "      <td>107</td>\n",
       "      <td>...</td>\n",
       "      <td>40</td>\n",
       "      <td>40</td>\n",
       "      <td>29</td>\n",
       "      <td>46</td>\n",
       "      <td>39</td>\n",
       "      <td>61</td>\n",
       "      <td>62</td>\n",
       "      <td>78</td>\n",
       "      <td>81</td>\n",
       "      <td>110</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>123</td>\n",
       "      <td>49</td>\n",
       "      <td>37</td>\n",
       "      <td>52</td>\n",
       "      <td>49</td>\n",
       "      <td>56</td>\n",
       "      <td>73</td>\n",
       "      <td>96</td>\n",
       "      <td>106</td>\n",
       "      <td>103</td>\n",
       "      <td>...</td>\n",
       "      <td>41</td>\n",
       "      <td>38</td>\n",
       "      <td>28</td>\n",
       "      <td>31</td>\n",
       "      <td>46</td>\n",
       "      <td>39</td>\n",
       "      <td>83</td>\n",
       "      <td>45</td>\n",
       "      <td>57</td>\n",
       "      <td>109</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>120</td>\n",
       "      <td>46</td>\n",
       "      <td>42</td>\n",
       "      <td>53</td>\n",
       "      <td>47</td>\n",
       "      <td>56</td>\n",
       "      <td>56</td>\n",
       "      <td>55</td>\n",
       "      <td>50</td>\n",
       "      <td>60</td>\n",
       "      <td>...</td>\n",
       "      <td>35</td>\n",
       "      <td>31</td>\n",
       "      <td>33</td>\n",
       "      <td>34</td>\n",
       "      <td>38</td>\n",
       "      <td>53</td>\n",
       "      <td>72</td>\n",
       "      <td>50</td>\n",
       "      <td>39</td>\n",
       "      <td>111</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>119</td>\n",
       "      <td>40</td>\n",
       "      <td>34</td>\n",
       "      <td>41</td>\n",
       "      <td>40</td>\n",
       "      <td>70</td>\n",
       "      <td>93</td>\n",
       "      <td>104</td>\n",
       "      <td>87</td>\n",
       "      <td>69</td>\n",
       "      <td>...</td>\n",
       "      <td>31</td>\n",
       "      <td>39</td>\n",
       "      <td>38</td>\n",
       "      <td>33</td>\n",
       "      <td>41</td>\n",
       "      <td>55</td>\n",
       "      <td>60</td>\n",
       "      <td>66</td>\n",
       "      <td>44</td>\n",
       "      <td>115</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>115</td>\n",
       "      <td>32</td>\n",
       "      <td>32</td>\n",
       "      <td>38</td>\n",
       "      <td>44</td>\n",
       "      <td>59</td>\n",
       "      <td>78</td>\n",
       "      <td>99</td>\n",
       "      <td>109</td>\n",
       "      <td>109</td>\n",
       "      <td>...</td>\n",
       "      <td>67</td>\n",
       "      <td>76</td>\n",
       "      <td>70</td>\n",
       "      <td>54</td>\n",
       "      <td>59</td>\n",
       "      <td>59</td>\n",
       "      <td>47</td>\n",
       "      <td>44</td>\n",
       "      <td>52</td>\n",
       "      <td>106</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>114</td>\n",
       "      <td>30</td>\n",
       "      <td>30</td>\n",
       "      <td>27</td>\n",
       "      <td>20</td>\n",
       "      <td>33</td>\n",
       "      <td>44</td>\n",
       "      <td>57</td>\n",
       "      <td>68</td>\n",
       "      <td>75</td>\n",
       "      <td>...</td>\n",
       "      <td>115</td>\n",
       "      <td>106</td>\n",
       "      <td>89</td>\n",
       "      <td>57</td>\n",
       "      <td>36</td>\n",
       "      <td>34</td>\n",
       "      <td>39</td>\n",
       "      <td>39</td>\n",
       "      <td>85</td>\n",
       "      <td>102</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>116</td>\n",
       "      <td>28</td>\n",
       "      <td>17</td>\n",
       "      <td>37</td>\n",
       "      <td>33</td>\n",
       "      <td>31</td>\n",
       "      <td>37</td>\n",
       "      <td>44</td>\n",
       "      <td>43</td>\n",
       "      <td>39</td>\n",
       "      <td>...</td>\n",
       "      <td>127</td>\n",
       "      <td>117</td>\n",
       "      <td>101</td>\n",
       "      <td>69</td>\n",
       "      <td>36</td>\n",
       "      <td>28</td>\n",
       "      <td>31</td>\n",
       "      <td>39</td>\n",
       "      <td>85</td>\n",
       "      <td>92</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>118</td>\n",
       "      <td>33</td>\n",
       "      <td>27</td>\n",
       "      <td>26</td>\n",
       "      <td>31</td>\n",
       "      <td>43</td>\n",
       "      <td>52</td>\n",
       "      <td>54</td>\n",
       "      <td>46</td>\n",
       "      <td>45</td>\n",
       "      <td>...</td>\n",
       "      <td>137</td>\n",
       "      <td>125</td>\n",
       "      <td>120</td>\n",
       "      <td>102</td>\n",
       "      <td>79</td>\n",
       "      <td>37</td>\n",
       "      <td>27</td>\n",
       "      <td>40</td>\n",
       "      <td>91</td>\n",
       "      <td>101</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>125</td>\n",
       "      <td>23</td>\n",
       "      <td>32</td>\n",
       "      <td>39</td>\n",
       "      <td>50</td>\n",
       "      <td>67</td>\n",
       "      <td>78</td>\n",
       "      <td>79</td>\n",
       "      <td>71</td>\n",
       "      <td>68</td>\n",
       "      <td>...</td>\n",
       "      <td>139</td>\n",
       "      <td>131</td>\n",
       "      <td>119</td>\n",
       "      <td>113</td>\n",
       "      <td>114</td>\n",
       "      <td>73</td>\n",
       "      <td>37</td>\n",
       "      <td>39</td>\n",
       "      <td>115</td>\n",
       "      <td>92</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>158</td>\n",
       "      <td>39</td>\n",
       "      <td>27</td>\n",
       "      <td>45</td>\n",
       "      <td>80</td>\n",
       "      <td>101</td>\n",
       "      <td>110</td>\n",
       "      <td>119</td>\n",
       "      <td>129</td>\n",
       "      <td>128</td>\n",
       "      <td>...</td>\n",
       "      <td>92</td>\n",
       "      <td>96</td>\n",
       "      <td>102</td>\n",
       "      <td>107</td>\n",
       "      <td>106</td>\n",
       "      <td>105</td>\n",
       "      <td>49</td>\n",
       "      <td>83</td>\n",
       "      <td>92</td>\n",
       "      <td>101</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>148</td>\n",
       "      <td>128</td>\n",
       "      <td>48</td>\n",
       "      <td>67</td>\n",
       "      <td>121</td>\n",
       "      <td>95</td>\n",
       "      <td>98</td>\n",
       "      <td>90</td>\n",
       "      <td>84</td>\n",
       "      <td>92</td>\n",
       "      <td>...</td>\n",
       "      <td>74</td>\n",
       "      <td>79</td>\n",
       "      <td>100</td>\n",
       "      <td>104</td>\n",
       "      <td>105</td>\n",
       "      <td>119</td>\n",
       "      <td>73</td>\n",
       "      <td>88</td>\n",
       "      <td>96</td>\n",
       "      <td>106</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>155</td>\n",
       "      <td>86</td>\n",
       "      <td>85</td>\n",
       "      <td>118</td>\n",
       "      <td>76</td>\n",
       "      <td>91</td>\n",
       "      <td>69</td>\n",
       "      <td>63</td>\n",
       "      <td>34</td>\n",
       "      <td>26</td>\n",
       "      <td>...</td>\n",
       "      <td>90</td>\n",
       "      <td>89</td>\n",
       "      <td>89</td>\n",
       "      <td>115</td>\n",
       "      <td>119</td>\n",
       "      <td>113</td>\n",
       "      <td>94</td>\n",
       "      <td>81</td>\n",
       "      <td>95</td>\n",
       "      <td>101</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>143</td>\n",
       "      <td>113</td>\n",
       "      <td>100</td>\n",
       "      <td>118</td>\n",
       "      <td>99</td>\n",
       "      <td>69</td>\n",
       "      <td>58</td>\n",
       "      <td>67</td>\n",
       "      <td>60</td>\n",
       "      <td>57</td>\n",
       "      <td>...</td>\n",
       "      <td>98</td>\n",
       "      <td>110</td>\n",
       "      <td>126</td>\n",
       "      <td>119</td>\n",
       "      <td>134</td>\n",
       "      <td>121</td>\n",
       "      <td>107</td>\n",
       "      <td>100</td>\n",
       "      <td>113</td>\n",
       "      <td>85</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>145</td>\n",
       "      <td>128</td>\n",
       "      <td>102</td>\n",
       "      <td>129</td>\n",
       "      <td>146</td>\n",
       "      <td>145</td>\n",
       "      <td>127</td>\n",
       "      <td>120</td>\n",
       "      <td>111</td>\n",
       "      <td>97</td>\n",
       "      <td>...</td>\n",
       "      <td>157</td>\n",
       "      <td>153</td>\n",
       "      <td>155</td>\n",
       "      <td>154</td>\n",
       "      <td>121</td>\n",
       "      <td>112</td>\n",
       "      <td>95</td>\n",
       "      <td>123</td>\n",
       "      <td>115</td>\n",
       "      <td>89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>141</td>\n",
       "      <td>132</td>\n",
       "      <td>134</td>\n",
       "      <td>119</td>\n",
       "      <td>143</td>\n",
       "      <td>158</td>\n",
       "      <td>158</td>\n",
       "      <td>159</td>\n",
       "      <td>159</td>\n",
       "      <td>170</td>\n",
       "      <td>...</td>\n",
       "      <td>166</td>\n",
       "      <td>151</td>\n",
       "      <td>153</td>\n",
       "      <td>126</td>\n",
       "      <td>126</td>\n",
       "      <td>99</td>\n",
       "      <td>102</td>\n",
       "      <td>116</td>\n",
       "      <td>88</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>151</td>\n",
       "      <td>85</td>\n",
       "      <td>164</td>\n",
       "      <td>98</td>\n",
       "      <td>126</td>\n",
       "      <td>139</td>\n",
       "      <td>149</td>\n",
       "      <td>159</td>\n",
       "      <td>171</td>\n",
       "      <td>178</td>\n",
       "      <td>...</td>\n",
       "      <td>157</td>\n",
       "      <td>154</td>\n",
       "      <td>140</td>\n",
       "      <td>122</td>\n",
       "      <td>105</td>\n",
       "      <td>104</td>\n",
       "      <td>94</td>\n",
       "      <td>95</td>\n",
       "      <td>74</td>\n",
       "      <td>77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>147</td>\n",
       "      <td>97</td>\n",
       "      <td>117</td>\n",
       "      <td>115</td>\n",
       "      <td>106</td>\n",
       "      <td>121</td>\n",
       "      <td>133</td>\n",
       "      <td>146</td>\n",
       "      <td>161</td>\n",
       "      <td>158</td>\n",
       "      <td>...</td>\n",
       "      <td>154</td>\n",
       "      <td>137</td>\n",
       "      <td>124</td>\n",
       "      <td>114</td>\n",
       "      <td>104</td>\n",
       "      <td>102</td>\n",
       "      <td>68</td>\n",
       "      <td>64</td>\n",
       "      <td>64</td>\n",
       "      <td>74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>155</td>\n",
       "      <td>87</td>\n",
       "      <td>80</td>\n",
       "      <td>108</td>\n",
       "      <td>103</td>\n",
       "      <td>111</td>\n",
       "      <td>122</td>\n",
       "      <td>132</td>\n",
       "      <td>132</td>\n",
       "      <td>141</td>\n",
       "      <td>...</td>\n",
       "      <td>134</td>\n",
       "      <td>124</td>\n",
       "      <td>111</td>\n",
       "      <td>106</td>\n",
       "      <td>108</td>\n",
       "      <td>99</td>\n",
       "      <td>67</td>\n",
       "      <td>62</td>\n",
       "      <td>58</td>\n",
       "      <td>62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>152</td>\n",
       "      <td>81</td>\n",
       "      <td>91</td>\n",
       "      <td>87</td>\n",
       "      <td>94</td>\n",
       "      <td>102</td>\n",
       "      <td>116</td>\n",
       "      <td>121</td>\n",
       "      <td>134</td>\n",
       "      <td>144</td>\n",
       "      <td>...</td>\n",
       "      <td>138</td>\n",
       "      <td>126</td>\n",
       "      <td>119</td>\n",
       "      <td>114</td>\n",
       "      <td>108</td>\n",
       "      <td>94</td>\n",
       "      <td>49</td>\n",
       "      <td>63</td>\n",
       "      <td>56</td>\n",
       "      <td>51</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>146</td>\n",
       "      <td>89</td>\n",
       "      <td>90</td>\n",
       "      <td>73</td>\n",
       "      <td>95</td>\n",
       "      <td>111</td>\n",
       "      <td>111</td>\n",
       "      <td>126</td>\n",
       "      <td>129</td>\n",
       "      <td>147</td>\n",
       "      <td>...</td>\n",
       "      <td>126</td>\n",
       "      <td>128</td>\n",
       "      <td>112</td>\n",
       "      <td>98</td>\n",
       "      <td>96</td>\n",
       "      <td>96</td>\n",
       "      <td>44</td>\n",
       "      <td>59</td>\n",
       "      <td>60</td>\n",
       "      <td>43</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>143</td>\n",
       "      <td>90</td>\n",
       "      <td>89</td>\n",
       "      <td>86</td>\n",
       "      <td>88</td>\n",
       "      <td>91</td>\n",
       "      <td>115</td>\n",
       "      <td>124</td>\n",
       "      <td>132</td>\n",
       "      <td>122</td>\n",
       "      <td>...</td>\n",
       "      <td>104</td>\n",
       "      <td>107</td>\n",
       "      <td>100</td>\n",
       "      <td>98</td>\n",
       "      <td>97</td>\n",
       "      <td>62</td>\n",
       "      <td>53</td>\n",
       "      <td>54</td>\n",
       "      <td>55</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>146</td>\n",
       "      <td>101</td>\n",
       "      <td>83</td>\n",
       "      <td>95</td>\n",
       "      <td>83</td>\n",
       "      <td>91</td>\n",
       "      <td>106</td>\n",
       "      <td>114</td>\n",
       "      <td>124</td>\n",
       "      <td>102</td>\n",
       "      <td>...</td>\n",
       "      <td>107</td>\n",
       "      <td>107</td>\n",
       "      <td>110</td>\n",
       "      <td>108</td>\n",
       "      <td>88</td>\n",
       "      <td>43</td>\n",
       "      <td>52</td>\n",
       "      <td>46</td>\n",
       "      <td>55</td>\n",
       "      <td>61</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>139</td>\n",
       "      <td>81</td>\n",
       "      <td>90</td>\n",
       "      <td>67</td>\n",
       "      <td>118</td>\n",
       "      <td>154</td>\n",
       "      <td>82</td>\n",
       "      <td>99</td>\n",
       "      <td>107</td>\n",
       "      <td>109</td>\n",
       "      <td>...</td>\n",
       "      <td>112</td>\n",
       "      <td>102</td>\n",
       "      <td>99</td>\n",
       "      <td>93</td>\n",
       "      <td>92</td>\n",
       "      <td>34</td>\n",
       "      <td>53</td>\n",
       "      <td>62</td>\n",
       "      <td>46</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>148</td>\n",
       "      <td>92</td>\n",
       "      <td>75</td>\n",
       "      <td>157</td>\n",
       "      <td>192</td>\n",
       "      <td>226</td>\n",
       "      <td>92</td>\n",
       "      <td>97</td>\n",
       "      <td>91</td>\n",
       "      <td>102</td>\n",
       "      <td>...</td>\n",
       "      <td>99</td>\n",
       "      <td>100</td>\n",
       "      <td>100</td>\n",
       "      <td>100</td>\n",
       "      <td>91</td>\n",
       "      <td>148</td>\n",
       "      <td>45</td>\n",
       "      <td>38</td>\n",
       "      <td>61</td>\n",
       "      <td>51</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>149</td>\n",
       "      <td>97</td>\n",
       "      <td>116</td>\n",
       "      <td>186</td>\n",
       "      <td>227</td>\n",
       "      <td>103</td>\n",
       "      <td>115</td>\n",
       "      <td>97</td>\n",
       "      <td>85</td>\n",
       "      <td>94</td>\n",
       "      <td>...</td>\n",
       "      <td>98</td>\n",
       "      <td>98</td>\n",
       "      <td>96</td>\n",
       "      <td>96</td>\n",
       "      <td>145</td>\n",
       "      <td>92</td>\n",
       "      <td>114</td>\n",
       "      <td>50</td>\n",
       "      <td>48</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>147</td>\n",
       "      <td>82</td>\n",
       "      <td>201</td>\n",
       "      <td>113</td>\n",
       "      <td>204</td>\n",
       "      <td>66</td>\n",
       "      <td>128</td>\n",
       "      <td>112</td>\n",
       "      <td>84</td>\n",
       "      <td>81</td>\n",
       "      <td>...</td>\n",
       "      <td>94</td>\n",
       "      <td>96</td>\n",
       "      <td>90</td>\n",
       "      <td>67</td>\n",
       "      <td>107</td>\n",
       "      <td>124</td>\n",
       "      <td>175</td>\n",
       "      <td>17</td>\n",
       "      <td>55</td>\n",
       "      <td>50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>164</td>\n",
       "      <td>105</td>\n",
       "      <td>225</td>\n",
       "      <td>162</td>\n",
       "      <td>170</td>\n",
       "      <td>134</td>\n",
       "      <td>124</td>\n",
       "      <td>122</td>\n",
       "      <td>111</td>\n",
       "      <td>74</td>\n",
       "      <td>...</td>\n",
       "      <td>91</td>\n",
       "      <td>90</td>\n",
       "      <td>93</td>\n",
       "      <td>67</td>\n",
       "      <td>86</td>\n",
       "      <td>169</td>\n",
       "      <td>150</td>\n",
       "      <td>82</td>\n",
       "      <td>73</td>\n",
       "      <td>56</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>205</td>\n",
       "      <td>220</td>\n",
       "      <td>204</td>\n",
       "      <td>185</td>\n",
       "      <td>213</td>\n",
       "      <td>119</td>\n",
       "      <td>121</td>\n",
       "      <td>118</td>\n",
       "      <td>117</td>\n",
       "      <td>92</td>\n",
       "      <td>...</td>\n",
       "      <td>86</td>\n",
       "      <td>95</td>\n",
       "      <td>81</td>\n",
       "      <td>49</td>\n",
       "      <td>141</td>\n",
       "      <td>94</td>\n",
       "      <td>171</td>\n",
       "      <td>134</td>\n",
       "      <td>142</td>\n",
       "      <td>124</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>252</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>252</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>32 rows × 32 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     0    1    2    3    4    5    6    7    8    9   ...   22   23   24   25  \\\n",
       "0   133  100   67   81  100   83   67   68   91  107  ...   67   80   76   79   \n",
       "1   169   78   66   92  101   93  113  107   79   72  ...   43   53   61   85   \n",
       "2   142   73   90   84  110  103  115  111  116  109  ...   43   50   49   79   \n",
       "3   142   75   59   76   73  105  121  120  108  107  ...   40   40   29   46   \n",
       "4   123   49   37   52   49   56   73   96  106  103  ...   41   38   28   31   \n",
       "5   120   46   42   53   47   56   56   55   50   60  ...   35   31   33   34   \n",
       "6   119   40   34   41   40   70   93  104   87   69  ...   31   39   38   33   \n",
       "7   115   32   32   38   44   59   78   99  109  109  ...   67   76   70   54   \n",
       "8   114   30   30   27   20   33   44   57   68   75  ...  115  106   89   57   \n",
       "9   116   28   17   37   33   31   37   44   43   39  ...  127  117  101   69   \n",
       "10  118   33   27   26   31   43   52   54   46   45  ...  137  125  120  102   \n",
       "11  125   23   32   39   50   67   78   79   71   68  ...  139  131  119  113   \n",
       "12  158   39   27   45   80  101  110  119  129  128  ...   92   96  102  107   \n",
       "13  148  128   48   67  121   95   98   90   84   92  ...   74   79  100  104   \n",
       "14  155   86   85  118   76   91   69   63   34   26  ...   90   89   89  115   \n",
       "15  143  113  100  118   99   69   58   67   60   57  ...   98  110  126  119   \n",
       "16  145  128  102  129  146  145  127  120  111   97  ...  157  153  155  154   \n",
       "17  141  132  134  119  143  158  158  159  159  170  ...  166  151  153  126   \n",
       "18  151   85  164   98  126  139  149  159  171  178  ...  157  154  140  122   \n",
       "19  147   97  117  115  106  121  133  146  161  158  ...  154  137  124  114   \n",
       "20  155   87   80  108  103  111  122  132  132  141  ...  134  124  111  106   \n",
       "21  152   81   91   87   94  102  116  121  134  144  ...  138  126  119  114   \n",
       "22  146   89   90   73   95  111  111  126  129  147  ...  126  128  112   98   \n",
       "23  143   90   89   86   88   91  115  124  132  122  ...  104  107  100   98   \n",
       "24  146  101   83   95   83   91  106  114  124  102  ...  107  107  110  108   \n",
       "25  139   81   90   67  118  154   82   99  107  109  ...  112  102   99   93   \n",
       "26  148   92   75  157  192  226   92   97   91  102  ...   99  100  100  100   \n",
       "27  149   97  116  186  227  103  115   97   85   94  ...   98   98   96   96   \n",
       "28  147   82  201  113  204   66  128  112   84   81  ...   94   96   90   67   \n",
       "29  164  105  225  162  170  134  124  122  111   74  ...   91   90   93   67   \n",
       "30  205  220  204  185  213  119  121  118  117   92  ...   86   95   81   49   \n",
       "31  255  254  255  255  252  254  255  255  255  254  ...  255  255  255  253   \n",
       "\n",
       "     26   27   28   29   30   31  \n",
       "0    87   81   99   95  106  107  \n",
       "1    56   86   84   79  106  102  \n",
       "2    61   76   86   83   97  102  \n",
       "3    39   61   62   78   81  110  \n",
       "4    46   39   83   45   57  109  \n",
       "5    38   53   72   50   39  111  \n",
       "6    41   55   60   66   44  115  \n",
       "7    59   59   47   44   52  106  \n",
       "8    36   34   39   39   85  102  \n",
       "9    36   28   31   39   85   92  \n",
       "10   79   37   27   40   91  101  \n",
       "11  114   73   37   39  115   92  \n",
       "12  106  105   49   83   92  101  \n",
       "13  105  119   73   88   96  106  \n",
       "14  119  113   94   81   95  101  \n",
       "15  134  121  107  100  113   85  \n",
       "16  121  112   95  123  115   89  \n",
       "17  126   99  102  116   88   93  \n",
       "18  105  104   94   95   74   77  \n",
       "19  104  102   68   64   64   74  \n",
       "20  108   99   67   62   58   62  \n",
       "21  108   94   49   63   56   51  \n",
       "22   96   96   44   59   60   43  \n",
       "23   97   62   53   54   55   55  \n",
       "24   88   43   52   46   55   61  \n",
       "25   92   34   53   62   46   44  \n",
       "26   91  148   45   38   61   51  \n",
       "27  145   92  114   50   48   55  \n",
       "28  107  124  175   17   55   50  \n",
       "29   86  169  150   82   73   56  \n",
       "30  141   94  171  134  142  124  \n",
       "31  255  255  255  255  252  255  \n",
       "\n",
       "[32 rows x 32 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 如果觉得numpy格式的arr不好观察，则可以通过pandas库将其转为DataFrame格式进行观察\n",
    "import pandas as pd\n",
    "pd.DataFrame(arr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[133 100  67 ... 255 252 255]]\n"
     ]
    }
   ],
   "source": [
    "# 上面获得的32*32的二维数组，还不利于数据建模，所以我们还需要通过reshape(1, -1)方法将其转换成一行(若reshape(-1,1)则转为一列），也即1*1024格式\n",
    "arr = arr.reshape(1, -1)\n",
    "\n",
    "print(arr)  # 查看转换后的结果，这一行数就是代表那张人脸图片了，其共有32*32=1024列数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "因为总共有400张照片需要处理，若将400个二维数组堆叠起来会形成三维数组，因为我们需要使用flatten()函数将1*1024的二维数组降维成一维数组，并通过tolist()函数将其转为列表方便之后和其他图片的颜色数值信息一起处理。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[133, 100, 67, 81, 100, 83, 67, 68, 91, 107, 107, 86, 55, 60, 48, 61, 42, 59, 48, 39, 66, 76, 67, 80, 76, 79, 87, 81, 99, 95, 106, 107, 169, 78, 66, 92, 101, 93, 113, 107, 79, 72, 78, 98, 90, 66, 69, 53, 54, 45, 37, 33, 62, 57, 43, 53, 61, 85, 56, 86, 84, 79, 106, 102, 142, 73, 90, 84, 110, 103, 115, 111, 116, 109, 101, 112, 95, 95, 72, 62, 52, 52, 52, 45, 37, 33, 43, 50, 49, 79, 61, 76, 86, 83, 97, 102, 142, 75, 59, 76, 73, 105, 121, 120, 108, 107, 96, 109, 78, 59, 81, 69, 64, 50, 57, 52, 55, 45, 40, 40, 29, 46, 39, 61, 62, 78, 81, 110, 123, 49, 37, 52, 49, 56, 73, 96, 106, 103, 88, 82, 103, 91, 70, 61, 62, 62, 58, 51, 56, 49, 41, 38, 28, 31, 46, 39, 83, 45, 57, 109, 120, 46, 42, 53, 47, 56, 56, 55, 50, 60, 73, 81, 98, 89, 69, 84, 75, 76, 62, 54, 57, 51, 35, 31, 33, 34, 38, 53, 72, 50, 39, 111, 119, 40, 34, 41, 40, 70, 93, 104, 87, 69, 72, 59, 56, 53, 41, 38, 66, 46, 43, 52, 39, 24, 31, 39, 38, 33, 41, 55, 60, 66, 44, 115, 115, 32, 32, 38, 44, 59, 78, 99, 109, 109, 106, 79, 74, 60, 41, 57, 64, 86, 89, 61, 53, 65, 67, 76, 70, 54, 59, 59, 47, 44, 52, 106, 114, 30, 30, 27, 20, 33, 44, 57, 68, 75, 71, 57, 58, 68, 71, 97, 91, 93, 113, 116, 113, 118, 115, 106, 89, 57, 36, 34, 39, 39, 85, 102, 116, 28, 17, 37, 33, 31, 37, 44, 43, 39, 42, 50, 51, 62, 79, 87, 101, 109, 115, 123, 123, 128, 127, 117, 101, 69, 36, 28, 31, 39, 85, 92, 118, 33, 27, 26, 31, 43, 52, 54, 46, 45, 50, 57, 68, 81, 95, 109, 119, 124, 132, 134, 135, 142, 137, 125, 120, 102, 79, 37, 27, 40, 91, 101, 125, 23, 32, 39, 50, 67, 78, 79, 71, 68, 75, 91, 108, 112, 116, 118, 123, 131, 143, 141, 140, 139, 139, 131, 119, 113, 114, 73, 37, 39, 115, 92, 158, 39, 27, 45, 80, 101, 110, 119, 129, 128, 124, 123, 123, 123, 120, 119, 117, 111, 108, 93, 91, 90, 92, 96, 102, 107, 106, 105, 49, 83, 92, 101, 148, 128, 48, 67, 121, 95, 98, 90, 84, 92, 98, 92, 114, 123, 129, 115, 83, 79, 47, 53, 53, 61, 74, 79, 100, 104, 105, 119, 73, 88, 96, 106, 155, 86, 85, 118, 76, 91, 69, 63, 34, 26, 44, 39, 57, 89, 129, 112, 79, 56, 45, 72, 60, 50, 90, 89, 89, 115, 119, 113, 94, 81, 95, 101, 143, 113, 100, 118, 99, 69, 58, 67, 60, 57, 71, 67, 54, 112, 182, 155, 104, 112, 95, 77, 93, 95, 98, 110, 126, 119, 134, 121, 107, 100, 113, 85, 145, 128, 102, 129, 146, 145, 127, 120, 111, 97, 97, 100, 120, 141, 174, 181, 134, 133, 134, 134, 133, 124, 157, 153, 155, 154, 121, 112, 95, 123, 115, 89, 141, 132, 134, 119, 143, 158, 158, 159, 159, 170, 174, 155, 134, 138, 169, 181, 143, 139, 143, 152, 170, 174, 166, 151, 153, 126, 126, 99, 102, 116, 88, 93, 151, 85, 164, 98, 126, 139, 149, 159, 171, 178, 168, 144, 131, 140, 174, 167, 152, 147, 136, 139, 151, 162, 157, 154, 140, 122, 105, 104, 94, 95, 74, 77, 147, 97, 117, 115, 106, 121, 133, 146, 161, 158, 145, 121, 152, 121, 155, 152, 122, 115, 123, 128, 145, 156, 154, 137, 124, 114, 104, 102, 68, 64, 64, 74, 155, 87, 80, 108, 103, 111, 122, 132, 132, 141, 139, 148, 53, 61, 66, 60, 58, 59, 76, 114, 155, 141, 134, 124, 111, 106, 108, 99, 67, 62, 58, 62, 152, 81, 91, 87, 94, 102, 116, 121, 134, 144, 151, 156, 131, 100, 84, 79, 95, 106, 121, 107, 143, 143, 138, 126, 119, 114, 108, 94, 49, 63, 56, 51, 146, 89, 90, 73, 95, 111, 111, 126, 129, 147, 137, 145, 144, 140, 151, 125, 105, 115, 120, 122, 122, 116, 126, 128, 112, 98, 96, 96, 44, 59, 60, 43, 143, 90, 89, 86, 88, 91, 115, 124, 132, 122, 126, 133, 113, 96, 78, 71, 61, 45, 57, 49, 47, 80, 104, 107, 100, 98, 97, 62, 53, 54, 55, 55, 146, 101, 83, 95, 83, 91, 106, 114, 124, 102, 96, 92, 93, 102, 121, 123, 137, 136, 118, 120, 127, 112, 107, 107, 110, 108, 88, 43, 52, 46, 55, 61, 139, 81, 90, 67, 118, 154, 82, 99, 107, 109, 115, 131, 118, 101, 107, 82, 83, 80, 103, 108, 112, 115, 112, 102, 99, 93, 92, 34, 53, 62, 46, 44, 148, 92, 75, 157, 192, 226, 92, 97, 91, 102, 111, 114, 114, 106, 92, 98, 102, 115, 104, 114, 120, 109, 99, 100, 100, 100, 91, 148, 45, 38, 61, 51, 149, 97, 116, 186, 227, 103, 115, 97, 85, 94, 110, 116, 120, 125, 135, 150, 145, 137, 138, 129, 117, 108, 98, 98, 96, 96, 145, 92, 114, 50, 48, 55, 147, 82, 201, 113, 204, 66, 128, 112, 84, 81, 91, 100, 112, 120, 120, 119, 116, 116, 110, 94, 88, 95, 94, 96, 90, 67, 107, 124, 175, 17, 55, 50, 164, 105, 225, 162, 170, 134, 124, 122, 111, 74, 71, 76, 83, 90, 91, 89, 84, 87, 83, 88, 98, 104, 91, 90, 93, 67, 86, 169, 150, 82, 73, 56, 205, 220, 204, 185, 213, 119, 121, 118, 117, 92, 79, 73, 72, 74, 75, 68, 74, 78, 78, 90, 90, 92, 86, 95, 81, 49, 141, 94, 171, 134, 142, 124, 255, 254, 255, 255, 252, 254, 255, 255, 255, 254, 255, 255, 255, 255, 255, 254, 255, 255, 255, 255, 253, 255, 255, 255, 255, 253, 255, 255, 255, 255, 252, 255]\n"
     ]
    }
   ],
   "source": [
    "print(arr.flatten().tolist())  # 下面这一行数就是那张人脸转换后的结果了"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 构造所有图片的特征变量\n",
    "X = []  # 特征变量\n",
    "for i in names:\n",
    "    img = Image.open('olivettifaces\\\\' + i)\n",
    "    img = img.convert('L')\n",
    "    img = img.resize((32, 32))\n",
    "    arr = np.array(img)\n",
    "    X.append(arr.reshape(1, -1).flatten().tolist())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>1014</th>\n",
       "      <th>1015</th>\n",
       "      <th>1016</th>\n",
       "      <th>1017</th>\n",
       "      <th>1018</th>\n",
       "      <th>1019</th>\n",
       "      <th>1020</th>\n",
       "      <th>1021</th>\n",
       "      <th>1022</th>\n",
       "      <th>1023</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>133</td>\n",
       "      <td>100</td>\n",
       "      <td>67</td>\n",
       "      <td>81</td>\n",
       "      <td>100</td>\n",
       "      <td>83</td>\n",
       "      <td>67</td>\n",
       "      <td>68</td>\n",
       "      <td>91</td>\n",
       "      <td>107</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>252</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>157</td>\n",
       "      <td>94</td>\n",
       "      <td>93</td>\n",
       "      <td>97</td>\n",
       "      <td>93</td>\n",
       "      <td>110</td>\n",
       "      <td>107</td>\n",
       "      <td>65</td>\n",
       "      <td>69</td>\n",
       "      <td>89</td>\n",
       "      <td>...</td>\n",
       "      <td>253</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>252</td>\n",
       "      <td>253</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>152</td>\n",
       "      <td>99</td>\n",
       "      <td>93</td>\n",
       "      <td>90</td>\n",
       "      <td>66</td>\n",
       "      <td>102</td>\n",
       "      <td>76</td>\n",
       "      <td>70</td>\n",
       "      <td>71</td>\n",
       "      <td>104</td>\n",
       "      <td>...</td>\n",
       "      <td>253</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>151</td>\n",
       "      <td>94</td>\n",
       "      <td>94</td>\n",
       "      <td>86</td>\n",
       "      <td>103</td>\n",
       "      <td>58</td>\n",
       "      <td>58</td>\n",
       "      <td>79</td>\n",
       "      <td>59</td>\n",
       "      <td>74</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>147</td>\n",
       "      <td>72</td>\n",
       "      <td>34</td>\n",
       "      <td>61</td>\n",
       "      <td>43</td>\n",
       "      <td>52</td>\n",
       "      <td>46</td>\n",
       "      <td>76</td>\n",
       "      <td>57</td>\n",
       "      <td>92</td>\n",
       "      <td>...</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>254</td>\n",
       "      <td>252</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>133</td>\n",
       "      <td>57</td>\n",
       "      <td>71</td>\n",
       "      <td>76</td>\n",
       "      <td>69</td>\n",
       "      <td>65</td>\n",
       "      <td>56</td>\n",
       "      <td>54</td>\n",
       "      <td>40</td>\n",
       "      <td>33</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>159</td>\n",
       "      <td>96</td>\n",
       "      <td>112</td>\n",
       "      <td>87</td>\n",
       "      <td>52</td>\n",
       "      <td>50</td>\n",
       "      <td>41</td>\n",
       "      <td>45</td>\n",
       "      <td>55</td>\n",
       "      <td>71</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>158</td>\n",
       "      <td>98</td>\n",
       "      <td>98</td>\n",
       "      <td>76</td>\n",
       "      <td>72</td>\n",
       "      <td>89</td>\n",
       "      <td>66</td>\n",
       "      <td>74</td>\n",
       "      <td>41</td>\n",
       "      <td>91</td>\n",
       "      <td>...</td>\n",
       "      <td>253</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>111</td>\n",
       "      <td>41</td>\n",
       "      <td>39</td>\n",
       "      <td>24</td>\n",
       "      <td>54</td>\n",
       "      <td>63</td>\n",
       "      <td>63</td>\n",
       "      <td>57</td>\n",
       "      <td>54</td>\n",
       "      <td>60</td>\n",
       "      <td>...</td>\n",
       "      <td>254</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>148</td>\n",
       "      <td>94</td>\n",
       "      <td>96</td>\n",
       "      <td>87</td>\n",
       "      <td>86</td>\n",
       "      <td>97</td>\n",
       "      <td>111</td>\n",
       "      <td>81</td>\n",
       "      <td>67</td>\n",
       "      <td>58</td>\n",
       "      <td>...</td>\n",
       "      <td>254</td>\n",
       "      <td>251</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>47</td>\n",
       "      <td>43</td>\n",
       "      <td>50</td>\n",
       "      <td>38</td>\n",
       "      <td>5</td>\n",
       "      <td>114</td>\n",
       "      <td>91</td>\n",
       "      <td>68</td>\n",
       "      <td>83</td>\n",
       "      <td>96</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>252</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>253</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>44</td>\n",
       "      <td>46</td>\n",
       "      <td>48</td>\n",
       "      <td>47</td>\n",
       "      <td>44</td>\n",
       "      <td>32</td>\n",
       "      <td>47</td>\n",
       "      <td>118</td>\n",
       "      <td>66</td>\n",
       "      <td>56</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>46</td>\n",
       "      <td>49</td>\n",
       "      <td>53</td>\n",
       "      <td>49</td>\n",
       "      <td>36</td>\n",
       "      <td>19</td>\n",
       "      <td>66</td>\n",
       "      <td>118</td>\n",
       "      <td>79</td>\n",
       "      <td>64</td>\n",
       "      <td>...</td>\n",
       "      <td>252</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>252</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>38</td>\n",
       "      <td>42</td>\n",
       "      <td>46</td>\n",
       "      <td>42</td>\n",
       "      <td>105</td>\n",
       "      <td>98</td>\n",
       "      <td>73</td>\n",
       "      <td>74</td>\n",
       "      <td>75</td>\n",
       "      <td>77</td>\n",
       "      <td>...</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>254</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>51</td>\n",
       "      <td>48</td>\n",
       "      <td>48</td>\n",
       "      <td>24</td>\n",
       "      <td>110</td>\n",
       "      <td>114</td>\n",
       "      <td>79</td>\n",
       "      <td>75</td>\n",
       "      <td>81</td>\n",
       "      <td>84</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>41</td>\n",
       "      <td>42</td>\n",
       "      <td>43</td>\n",
       "      <td>44</td>\n",
       "      <td>43</td>\n",
       "      <td>35</td>\n",
       "      <td>57</td>\n",
       "      <td>27</td>\n",
       "      <td>77</td>\n",
       "      <td>53</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>37</td>\n",
       "      <td>43</td>\n",
       "      <td>46</td>\n",
       "      <td>43</td>\n",
       "      <td>24</td>\n",
       "      <td>82</td>\n",
       "      <td>85</td>\n",
       "      <td>87</td>\n",
       "      <td>91</td>\n",
       "      <td>86</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>45</td>\n",
       "      <td>53</td>\n",
       "      <td>50</td>\n",
       "      <td>48</td>\n",
       "      <td>43</td>\n",
       "      <td>69</td>\n",
       "      <td>84</td>\n",
       "      <td>80</td>\n",
       "      <td>72</td>\n",
       "      <td>56</td>\n",
       "      <td>...</td>\n",
       "      <td>254</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>37</td>\n",
       "      <td>39</td>\n",
       "      <td>38</td>\n",
       "      <td>42</td>\n",
       "      <td>38</td>\n",
       "      <td>42</td>\n",
       "      <td>45</td>\n",
       "      <td>31</td>\n",
       "      <td>27</td>\n",
       "      <td>25</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>254</td>\n",
       "      <td>252</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>45</td>\n",
       "      <td>45</td>\n",
       "      <td>44</td>\n",
       "      <td>44</td>\n",
       "      <td>41</td>\n",
       "      <td>45</td>\n",
       "      <td>41</td>\n",
       "      <td>63</td>\n",
       "      <td>30</td>\n",
       "      <td>77</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>250</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>112</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>20</td>\n",
       "      <td>22</td>\n",
       "      <td>25</td>\n",
       "      <td>22</td>\n",
       "      <td>23</td>\n",
       "      <td>27</td>\n",
       "      <td>32</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>111</td>\n",
       "      <td>18</td>\n",
       "      <td>18</td>\n",
       "      <td>20</td>\n",
       "      <td>11</td>\n",
       "      <td>31</td>\n",
       "      <td>16</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>40</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>252</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>110</td>\n",
       "      <td>14</td>\n",
       "      <td>15</td>\n",
       "      <td>17</td>\n",
       "      <td>8</td>\n",
       "      <td>28</td>\n",
       "      <td>7</td>\n",
       "      <td>16</td>\n",
       "      <td>20</td>\n",
       "      <td>45</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>113</td>\n",
       "      <td>21</td>\n",
       "      <td>21</td>\n",
       "      <td>26</td>\n",
       "      <td>21</td>\n",
       "      <td>24</td>\n",
       "      <td>27</td>\n",
       "      <td>22</td>\n",
       "      <td>16</td>\n",
       "      <td>25</td>\n",
       "      <td>...</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>108</td>\n",
       "      <td>20</td>\n",
       "      <td>12</td>\n",
       "      <td>14</td>\n",
       "      <td>15</td>\n",
       "      <td>18</td>\n",
       "      <td>7</td>\n",
       "      <td>16</td>\n",
       "      <td>43</td>\n",
       "      <td>59</td>\n",
       "      <td>...</td>\n",
       "      <td>251</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>109</td>\n",
       "      <td>17</td>\n",
       "      <td>18</td>\n",
       "      <td>19</td>\n",
       "      <td>14</td>\n",
       "      <td>22</td>\n",
       "      <td>14</td>\n",
       "      <td>23</td>\n",
       "      <td>19</td>\n",
       "      <td>7</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>110</td>\n",
       "      <td>20</td>\n",
       "      <td>19</td>\n",
       "      <td>27</td>\n",
       "      <td>24</td>\n",
       "      <td>18</td>\n",
       "      <td>30</td>\n",
       "      <td>55</td>\n",
       "      <td>69</td>\n",
       "      <td>76</td>\n",
       "      <td>...</td>\n",
       "      <td>254</td>\n",
       "      <td>254</td>\n",
       "      <td>253</td>\n",
       "      <td>253</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>105</td>\n",
       "      <td>15</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>11</td>\n",
       "      <td>16</td>\n",
       "      <td>12</td>\n",
       "      <td>13</td>\n",
       "      <td>16</td>\n",
       "      <td>8</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>252</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>110</td>\n",
       "      <td>16</td>\n",
       "      <td>17</td>\n",
       "      <td>17</td>\n",
       "      <td>16</td>\n",
       "      <td>18</td>\n",
       "      <td>19</td>\n",
       "      <td>21</td>\n",
       "      <td>13</td>\n",
       "      <td>9</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>106</td>\n",
       "      <td>14</td>\n",
       "      <td>13</td>\n",
       "      <td>12</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>11</td>\n",
       "      <td>10</td>\n",
       "      <td>13</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>370</th>\n",
       "      <td>110</td>\n",
       "      <td>53</td>\n",
       "      <td>42</td>\n",
       "      <td>25</td>\n",
       "      <td>30</td>\n",
       "      <td>92</td>\n",
       "      <td>115</td>\n",
       "      <td>95</td>\n",
       "      <td>105</td>\n",
       "      <td>121</td>\n",
       "      <td>...</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>371</th>\n",
       "      <td>124</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>68</td>\n",
       "      <td>102</td>\n",
       "      <td>135</td>\n",
       "      <td>154</td>\n",
       "      <td>108</td>\n",
       "      <td>139</td>\n",
       "      <td>136</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>253</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>372</th>\n",
       "      <td>121</td>\n",
       "      <td>47</td>\n",
       "      <td>67</td>\n",
       "      <td>103</td>\n",
       "      <td>113</td>\n",
       "      <td>94</td>\n",
       "      <td>101</td>\n",
       "      <td>128</td>\n",
       "      <td>130</td>\n",
       "      <td>131</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>251</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>373</th>\n",
       "      <td>133</td>\n",
       "      <td>39</td>\n",
       "      <td>51</td>\n",
       "      <td>55</td>\n",
       "      <td>133</td>\n",
       "      <td>120</td>\n",
       "      <td>96</td>\n",
       "      <td>106</td>\n",
       "      <td>71</td>\n",
       "      <td>42</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>253</td>\n",
       "      <td>253</td>\n",
       "      <td>254</td>\n",
       "      <td>253</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>374</th>\n",
       "      <td>112</td>\n",
       "      <td>31</td>\n",
       "      <td>44</td>\n",
       "      <td>35</td>\n",
       "      <td>21</td>\n",
       "      <td>56</td>\n",
       "      <td>124</td>\n",
       "      <td>102</td>\n",
       "      <td>92</td>\n",
       "      <td>91</td>\n",
       "      <td>...</td>\n",
       "      <td>252</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>375</th>\n",
       "      <td>122</td>\n",
       "      <td>35</td>\n",
       "      <td>36</td>\n",
       "      <td>33</td>\n",
       "      <td>36</td>\n",
       "      <td>42</td>\n",
       "      <td>22</td>\n",
       "      <td>56</td>\n",
       "      <td>105</td>\n",
       "      <td>106</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>254</td>\n",
       "      <td>253</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>376</th>\n",
       "      <td>112</td>\n",
       "      <td>41</td>\n",
       "      <td>36</td>\n",
       "      <td>24</td>\n",
       "      <td>25</td>\n",
       "      <td>26</td>\n",
       "      <td>33</td>\n",
       "      <td>34</td>\n",
       "      <td>32</td>\n",
       "      <td>54</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>377</th>\n",
       "      <td>117</td>\n",
       "      <td>35</td>\n",
       "      <td>33</td>\n",
       "      <td>36</td>\n",
       "      <td>42</td>\n",
       "      <td>31</td>\n",
       "      <td>89</td>\n",
       "      <td>182</td>\n",
       "      <td>122</td>\n",
       "      <td>127</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>252</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>378</th>\n",
       "      <td>120</td>\n",
       "      <td>34</td>\n",
       "      <td>29</td>\n",
       "      <td>33</td>\n",
       "      <td>30</td>\n",
       "      <td>33</td>\n",
       "      <td>36</td>\n",
       "      <td>34</td>\n",
       "      <td>95</td>\n",
       "      <td>107</td>\n",
       "      <td>...</td>\n",
       "      <td>252</td>\n",
       "      <td>254</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>379</th>\n",
       "      <td>115</td>\n",
       "      <td>31</td>\n",
       "      <td>37</td>\n",
       "      <td>34</td>\n",
       "      <td>33</td>\n",
       "      <td>33</td>\n",
       "      <td>31</td>\n",
       "      <td>26</td>\n",
       "      <td>48</td>\n",
       "      <td>96</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>380</th>\n",
       "      <td>130</td>\n",
       "      <td>53</td>\n",
       "      <td>56</td>\n",
       "      <td>51</td>\n",
       "      <td>52</td>\n",
       "      <td>56</td>\n",
       "      <td>54</td>\n",
       "      <td>49</td>\n",
       "      <td>37</td>\n",
       "      <td>29</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>254</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>381</th>\n",
       "      <td>129</td>\n",
       "      <td>48</td>\n",
       "      <td>44</td>\n",
       "      <td>49</td>\n",
       "      <td>51</td>\n",
       "      <td>46</td>\n",
       "      <td>31</td>\n",
       "      <td>14</td>\n",
       "      <td>13</td>\n",
       "      <td>23</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>382</th>\n",
       "      <td>128</td>\n",
       "      <td>51</td>\n",
       "      <td>50</td>\n",
       "      <td>47</td>\n",
       "      <td>52</td>\n",
       "      <td>53</td>\n",
       "      <td>53</td>\n",
       "      <td>47</td>\n",
       "      <td>39</td>\n",
       "      <td>31</td>\n",
       "      <td>...</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>383</th>\n",
       "      <td>134</td>\n",
       "      <td>54</td>\n",
       "      <td>51</td>\n",
       "      <td>48</td>\n",
       "      <td>54</td>\n",
       "      <td>60</td>\n",
       "      <td>48</td>\n",
       "      <td>31</td>\n",
       "      <td>25</td>\n",
       "      <td>26</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>384</th>\n",
       "      <td>129</td>\n",
       "      <td>49</td>\n",
       "      <td>52</td>\n",
       "      <td>52</td>\n",
       "      <td>53</td>\n",
       "      <td>48</td>\n",
       "      <td>32</td>\n",
       "      <td>21</td>\n",
       "      <td>25</td>\n",
       "      <td>25</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>252</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>254</td>\n",
       "      <td>253</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>385</th>\n",
       "      <td>129</td>\n",
       "      <td>48</td>\n",
       "      <td>46</td>\n",
       "      <td>46</td>\n",
       "      <td>55</td>\n",
       "      <td>56</td>\n",
       "      <td>53</td>\n",
       "      <td>45</td>\n",
       "      <td>36</td>\n",
       "      <td>30</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>252</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>386</th>\n",
       "      <td>129</td>\n",
       "      <td>47</td>\n",
       "      <td>48</td>\n",
       "      <td>46</td>\n",
       "      <td>47</td>\n",
       "      <td>53</td>\n",
       "      <td>57</td>\n",
       "      <td>50</td>\n",
       "      <td>48</td>\n",
       "      <td>39</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>387</th>\n",
       "      <td>127</td>\n",
       "      <td>47</td>\n",
       "      <td>48</td>\n",
       "      <td>47</td>\n",
       "      <td>47</td>\n",
       "      <td>58</td>\n",
       "      <td>54</td>\n",
       "      <td>41</td>\n",
       "      <td>27</td>\n",
       "      <td>22</td>\n",
       "      <td>...</td>\n",
       "      <td>254</td>\n",
       "      <td>254</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>388</th>\n",
       "      <td>132</td>\n",
       "      <td>56</td>\n",
       "      <td>58</td>\n",
       "      <td>53</td>\n",
       "      <td>51</td>\n",
       "      <td>62</td>\n",
       "      <td>53</td>\n",
       "      <td>33</td>\n",
       "      <td>23</td>\n",
       "      <td>29</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>253</td>\n",
       "      <td>252</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>389</th>\n",
       "      <td>132</td>\n",
       "      <td>56</td>\n",
       "      <td>55</td>\n",
       "      <td>56</td>\n",
       "      <td>52</td>\n",
       "      <td>41</td>\n",
       "      <td>31</td>\n",
       "      <td>30</td>\n",
       "      <td>29</td>\n",
       "      <td>32</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>253</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>390</th>\n",
       "      <td>106</td>\n",
       "      <td>111</td>\n",
       "      <td>107</td>\n",
       "      <td>101</td>\n",
       "      <td>120</td>\n",
       "      <td>111</td>\n",
       "      <td>118</td>\n",
       "      <td>100</td>\n",
       "      <td>111</td>\n",
       "      <td>102</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>391</th>\n",
       "      <td>100</td>\n",
       "      <td>102</td>\n",
       "      <td>107</td>\n",
       "      <td>106</td>\n",
       "      <td>110</td>\n",
       "      <td>100</td>\n",
       "      <td>123</td>\n",
       "      <td>102</td>\n",
       "      <td>93</td>\n",
       "      <td>130</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>392</th>\n",
       "      <td>113</td>\n",
       "      <td>107</td>\n",
       "      <td>111</td>\n",
       "      <td>117</td>\n",
       "      <td>111</td>\n",
       "      <td>119</td>\n",
       "      <td>142</td>\n",
       "      <td>174</td>\n",
       "      <td>197</td>\n",
       "      <td>197</td>\n",
       "      <td>...</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>393</th>\n",
       "      <td>103</td>\n",
       "      <td>98</td>\n",
       "      <td>106</td>\n",
       "      <td>117</td>\n",
       "      <td>102</td>\n",
       "      <td>103</td>\n",
       "      <td>122</td>\n",
       "      <td>146</td>\n",
       "      <td>172</td>\n",
       "      <td>191</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>394</th>\n",
       "      <td>112</td>\n",
       "      <td>106</td>\n",
       "      <td>115</td>\n",
       "      <td>120</td>\n",
       "      <td>107</td>\n",
       "      <td>110</td>\n",
       "      <td>124</td>\n",
       "      <td>116</td>\n",
       "      <td>98</td>\n",
       "      <td>120</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>252</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>395</th>\n",
       "      <td>111</td>\n",
       "      <td>117</td>\n",
       "      <td>121</td>\n",
       "      <td>126</td>\n",
       "      <td>114</td>\n",
       "      <td>117</td>\n",
       "      <td>115</td>\n",
       "      <td>112</td>\n",
       "      <td>111</td>\n",
       "      <td>118</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>396</th>\n",
       "      <td>115</td>\n",
       "      <td>119</td>\n",
       "      <td>117</td>\n",
       "      <td>113</td>\n",
       "      <td>129</td>\n",
       "      <td>118</td>\n",
       "      <td>117</td>\n",
       "      <td>114</td>\n",
       "      <td>113</td>\n",
       "      <td>118</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>254</td>\n",
       "      <td>254</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>397</th>\n",
       "      <td>116</td>\n",
       "      <td>117</td>\n",
       "      <td>112</td>\n",
       "      <td>113</td>\n",
       "      <td>123</td>\n",
       "      <td>119</td>\n",
       "      <td>114</td>\n",
       "      <td>117</td>\n",
       "      <td>126</td>\n",
       "      <td>112</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>250</td>\n",
       "      <td>255</td>\n",
       "      <td>252</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>398</th>\n",
       "      <td>109</td>\n",
       "      <td>108</td>\n",
       "      <td>109</td>\n",
       "      <td>110</td>\n",
       "      <td>109</td>\n",
       "      <td>117</td>\n",
       "      <td>106</td>\n",
       "      <td>113</td>\n",
       "      <td>109</td>\n",
       "      <td>119</td>\n",
       "      <td>...</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>255</td>\n",
       "      <td>253</td>\n",
       "      <td>254</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>399</th>\n",
       "      <td>106</td>\n",
       "      <td>113</td>\n",
       "      <td>109</td>\n",
       "      <td>112</td>\n",
       "      <td>118</td>\n",
       "      <td>110</td>\n",
       "      <td>118</td>\n",
       "      <td>120</td>\n",
       "      <td>113</td>\n",
       "      <td>90</td>\n",
       "      <td>...</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>254</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "      <td>255</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>400 rows × 1024 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     0     1     2     3     4     5     6     7     8     9     ...  1014  \\\n",
       "0     133   100    67    81   100    83    67    68    91   107  ...   255   \n",
       "1     157    94    93    97    93   110   107    65    69    89  ...   253   \n",
       "2     152    99    93    90    66   102    76    70    71   104  ...   253   \n",
       "3     151    94    94    86   103    58    58    79    59    74  ...   255   \n",
       "4     147    72    34    61    43    52    46    76    57    92  ...   254   \n",
       "5     133    57    71    76    69    65    56    54    40    33  ...   255   \n",
       "6     159    96   112    87    52    50    41    45    55    71  ...   255   \n",
       "7     158    98    98    76    72    89    66    74    41    91  ...   253   \n",
       "8     111    41    39    24    54    63    63    57    54    60  ...   254   \n",
       "9     148    94    96    87    86    97   111    81    67    58  ...   254   \n",
       "10     47    43    50    38     5   114    91    68    83    96  ...   255   \n",
       "11     44    46    48    47    44    32    47   118    66    56  ...   255   \n",
       "12     46    49    53    49    36    19    66   118    79    64  ...   252   \n",
       "13     38    42    46    42   105    98    73    74    75    77  ...   254   \n",
       "14     51    48    48    24   110   114    79    75    81    84  ...   255   \n",
       "15     41    42    43    44    43    35    57    27    77    53  ...   255   \n",
       "16     37    43    46    43    24    82    85    87    91    86  ...   255   \n",
       "17     45    53    50    48    43    69    84    80    72    56  ...   254   \n",
       "18     37    39    38    42    38    42    45    31    27    25  ...   255   \n",
       "19     45    45    44    44    41    45    41    63    30    77  ...   255   \n",
       "20    112    22    21    20    22    25    22    23    27    32  ...   255   \n",
       "21    111    18    18    20    11    31    16    15    15    40  ...   255   \n",
       "22    110    14    15    17     8    28     7    16    20    45  ...   255   \n",
       "23    113    21    21    26    21    24    27    22    16    25  ...   254   \n",
       "24    108    20    12    14    15    18     7    16    43    59  ...   251   \n",
       "25    109    17    18    19    14    22    14    23    19     7  ...   255   \n",
       "26    110    20    19    27    24    18    30    55    69    76  ...   254   \n",
       "27    105    15    14    14    11    16    12    13    16     8  ...   255   \n",
       "28    110    16    17    17    16    18    19    21    13     9  ...   255   \n",
       "29    106    14    13    12    13    13    13    11    10    13  ...   255   \n",
       "..    ...   ...   ...   ...   ...   ...   ...   ...   ...   ...  ...   ...   \n",
       "370   110    53    42    25    30    92   115    95   105   121  ...   254   \n",
       "371   124    20    28    68   102   135   154   108   139   136  ...   255   \n",
       "372   121    47    67   103   113    94   101   128   130   131  ...   255   \n",
       "373   133    39    51    55   133   120    96   106    71    42  ...   255   \n",
       "374   112    31    44    35    21    56   124   102    92    91  ...   252   \n",
       "375   122    35    36    33    36    42    22    56   105   106  ...   255   \n",
       "376   112    41    36    24    25    26    33    34    32    54  ...   255   \n",
       "377   117    35    33    36    42    31    89   182   122   127  ...   255   \n",
       "378   120    34    29    33    30    33    36    34    95   107  ...   252   \n",
       "379   115    31    37    34    33    33    31    26    48    96  ...   255   \n",
       "380   130    53    56    51    52    56    54    49    37    29  ...   255   \n",
       "381   129    48    44    49    51    46    31    14    13    23  ...   255   \n",
       "382   128    51    50    47    52    53    53    47    39    31  ...   254   \n",
       "383   134    54    51    48    54    60    48    31    25    26  ...   255   \n",
       "384   129    49    52    52    53    48    32    21    25    25  ...   255   \n",
       "385   129    48    46    46    55    56    53    45    36    30  ...   255   \n",
       "386   129    47    48    46    47    53    57    50    48    39  ...   255   \n",
       "387   127    47    48    47    47    58    54    41    27    22  ...   254   \n",
       "388   132    56    58    53    51    62    53    33    23    29  ...   255   \n",
       "389   132    56    55    56    52    41    31    30    29    32  ...   255   \n",
       "390   106   111   107   101   120   111   118   100   111   102  ...   255   \n",
       "391   100   102   107   106   110   100   123   102    93   130  ...   255   \n",
       "392   113   107   111   117   111   119   142   174   197   197  ...   254   \n",
       "393   103    98   106   117   102   103   122   146   172   191  ...   255   \n",
       "394   112   106   115   120   107   110   124   116    98   120  ...   255   \n",
       "395   111   117   121   126   114   117   115   112   111   118  ...   255   \n",
       "396   115   119   117   113   129   118   117   114   113   118  ...   255   \n",
       "397   116   117   112   113   123   119   114   117   126   112  ...   255   \n",
       "398   109   108   109   110   109   117   106   113   109   119  ...   254   \n",
       "399   106   113   109   112   118   110   118   120   113    90  ...   255   \n",
       "\n",
       "     1015  1016  1017  1018  1019  1020  1021  1022  1023  \n",
       "0     255   255   253   255   255   255   255   252   255  \n",
       "1     254   255   254   252   253   255   255   254   255  \n",
       "2     254   255   254   255   253   255   255   255   255  \n",
       "3     255   255   255   253   254   255   255   254   255  \n",
       "4     255   254   254   252   254   255   254   254   255  \n",
       "5     255   255   255   255   255   255   255   254   255  \n",
       "6     255   254   255   253   254   255   255   255   254  \n",
       "7     255   253   254   255   255   255   254   255   255  \n",
       "8     254   255   255   255   254   255   254   254   255  \n",
       "9     251   255   254   254   255   254   255   255   255  \n",
       "10    252   255   254   255   254   255   253   253   255  \n",
       "11    253   255   254   255   254   255   255   254   255  \n",
       "12    255   255   253   254   255   255   252   254   255  \n",
       "13    255   253   255   255   254   255   255   254   254  \n",
       "14    255   254   255   254   255   255   255   255   255  \n",
       "15    254   255   255   253   255   253   255   255   253  \n",
       "16    254   255   255   255   255   255   254   255   255  \n",
       "17    254   255   253   255   254   255   255   255   255  \n",
       "18    255   255   255   255   253   255   254   254   252  \n",
       "19    255   250   255   255   253   255   255   255   255  \n",
       "20    255   253   255   255   254   254   255   255   255  \n",
       "21    255   254   255   252   255   255   255   255   254  \n",
       "22    254   255   255   255   255   254   255   255   254  \n",
       "23    255   255   253   254   255   255   253   255   255  \n",
       "24    254   255   255   255   255   255   255   255   255  \n",
       "25    254   254   255   255   255   254   255   254   255  \n",
       "26    254   253   253   255   255   255   255   254   255  \n",
       "27    252   255   255   255   254   255   253   255   255  \n",
       "28    255   255   255   255   255   255   254   254   255  \n",
       "29    255   254   255   255   255   255   254   255   255  \n",
       "..    ...   ...   ...   ...   ...   ...   ...   ...   ...  \n",
       "370   255   254   254   255   255   255   254   255   255  \n",
       "371   254   253   255   255   255   255   255   255   255  \n",
       "372   255   255   251   255   255   255   255   255   255  \n",
       "373   254   253   253   254   253   254   255   255   255  \n",
       "374   255   255   255   255   255   253   255   253   255  \n",
       "375   255   254   254   253   255   255   255   255   255  \n",
       "376   255   255   255   253   254   255   255   255   255  \n",
       "377   255   254   252   255   255   255   255   255   255  \n",
       "378   254   254   255   255   255   255   255   254   255  \n",
       "379   254   255   254   255   255   255   254   255   255  \n",
       "380   254   254   255   255   255   255   255   253   254  \n",
       "381   255   254   255   255   255   255   255   255   255  \n",
       "382   255   255   255   255   255   255   254   255   255  \n",
       "383   255   255   255   255   255   254   255   255   255  \n",
       "384   255   255   252   255   255   255   253   254   253  \n",
       "385   255   253   252   255   255   254   254   255   255  \n",
       "386   254   255   255   255   253   255   255   254   255  \n",
       "387   254   254   255   255   255   254   255   254   255  \n",
       "388   255   255   255   254   253   252   255   255   255  \n",
       "389   255   253   255   254   253   255   255   255   254  \n",
       "390   254   255   254   255   255   255   255   255   253  \n",
       "391   255   255   255   255   255   255   255   255   254  \n",
       "392   255   253   254   255   255   255   254   255   254  \n",
       "393   255   255   255   254   255   255   255   255   255  \n",
       "394   255   255   255   252   254   255   254   255   255  \n",
       "395   255   255   254   254   255   254   254   255   253  \n",
       "396   255   255   255   255   254   255   254   254   254  \n",
       "397   255   255   250   255   252   255   255   255   253  \n",
       "398   255   255   255   254   255   253   255   253   254  \n",
       "399   255   254   255   255   255   255   255   255   255  \n",
       "\n",
       "[400 rows x 1024 columns]"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "X = pd.DataFrame(X)\n",
    "\n",
    "X  # 查看400张图片转换后的结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(400, 1024)\n"
     ]
    }
   ],
   "source": [
    "print(X.shape)  # 查看此时的表格结构"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3.人脸数据处理 - 目标变量提取"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n"
     ]
    }
   ],
   "source": [
    "# 获取目标变量y：第一张图片演示\n",
    "print(int(names[0].split('_')[0]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n"
     ]
    }
   ],
   "source": [
    "# 批量获取所有图片的目标变量y\n",
    "y = []  # 目标变量\n",
    "for i in names:\n",
    "    img = Image.open('olivettifaces\\\\' + i)\n",
    "    y.append(int(i.split('_')[0]))\n",
    "    \n",
    "print(y)  # 查看目标变量,也就是对应的人员编号"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 12.2.3 数据划分与降维"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1.划分训练集和测试集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2.PCA数据降维"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "PCA(copy=True, iterated_power='auto', n_components=100, random_state=None,\n",
       "    svd_solver='auto', tol=0.0, whiten=False)"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 数据降维模型训练\n",
    "from sklearn.decomposition import PCA\n",
    "pca = PCA(n_components=100)\n",
    "pca.fit(X_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 对训练集和测试集进行数据降维\n",
    "X_train_pca = pca.transform(X_train)\n",
    "X_test_pca = pca.transform(X_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(320, 100)\n",
      "(80, 100)\n"
     ]
    }
   ],
   "source": [
    "# 我们通过如下代码验证PCA是否降维：\n",
    "print(X_train_pca.shape)\n",
    "print(X_test_pca.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 如果想查看此时降维后的X_train_pca和X_test_pca，可以直接将它们打印出来查看，也可以将它们转为DataFrame格式进行查看，代码如下：\n",
    "# pd.DataFrame(X_train_pca).head()\n",
    "# pd.DataFrame(X_test_pca).head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 在PCA后面加个“？”运行可以可以看看官方的一些提示\n",
    "# PCA?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 12.2.4 模型的搭建与使用"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1.模型搭建"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "KNeighborsClassifier(algorithm='auto', leaf_size=30, metric='minkowski',\n",
       "                     metric_params=None, n_jobs=None, n_neighbors=5, p=2,\n",
       "                     weights='uniform')"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.neighbors import KNeighborsClassifier\n",
    "knn = KNeighborsClassifier()  # 建立KNN模型  \n",
    "knn.fit(X_train_pca, y_train)  # 用降维后的训练集进行训练模型"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2.模型预测"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 9 21  3 40 26  4 28 37 12 36 26  7 27 21  3 24  7  2 17 30 21 32  8  2\n",
      " 11 19  6 29  6 29 18 10 25 35 10 18 15  5  9 22 34 29  2 16  8 18  8 38\n",
      " 39 35 16 30 30 11 37 36 35 20 33  6  1 16 31 32  5 30 21 39 35 39  2 19\n",
      "  5  8 11  4 14 27 22 30]\n"
     ]
    }
   ],
   "source": [
    "y_pred = knn.predict(X_test_pca)  # 用降维后的测试集进行测试\n",
    "print(y_pred)  # 将对测试集的预测结果打印出来"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>预测值</th>\n",
       "      <th>实际值</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>21</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>40</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>26</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   预测值  实际值\n",
       "0    9    9\n",
       "1   21   21\n",
       "2    3    3\n",
       "3   40   40\n",
       "4   26   26"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 通过和之前章节类似的代码，我们可以将预测值和实际值进行对比：\n",
    "import pandas as pd\n",
    "a = pd.DataFrame()  # 创建一个空DataFrame \n",
    "a['预测值'] = list(y_pred)\n",
    "a['实际值'] = list(y_test)\n",
    "\n",
    "a.head()  # 查看表格前5行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.925\n"
     ]
    }
   ],
   "source": [
    "# 查看预测准确度 - 方法1\n",
    "from sklearn.metrics import accuracy_score\n",
    "score = accuracy_score(y_pred, y_test)\n",
    "print(score)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.925\n"
     ]
    }
   ],
   "source": [
    "# 查看预测准确度 - 方法2\n",
    "score = knn.score(X_test_pca, y_test)\n",
    "print(score)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3.模型对比（数据降维与不降维）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.9125\n"
     ]
    }
   ],
   "source": [
    "from sklearn.neighbors import KNeighborsClassifier\n",
    "knn = KNeighborsClassifier()  # 建立KNN模型  \n",
    "knn.fit(X_train, y_train)  # 不使用数据降维，直接训练\n",
    "y_pred = knn.predict(X_test)  # 不使用数据降维，直接测试\n",
    "\n",
    "from sklearn.metrics import accuracy_score\n",
    "score = accuracy_score(y_pred, y_test)\n",
    "print(score)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "此时获得的准确度评分score为0.91，可以看到使用数据降维对提高模型预测效果还是有一些效果的，这里的数据量并不大，当数据量更大的时候，利用PCA主成分分析进行数据降维则会发挥更大的作用。"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
